/*
 * @Author: TJN tjn@246@126.com
 * @Date: 2024-06-21 16:06:26
 * @LastEditors: TJN tjn@246@126.com
 * @LastEditTime: 2024-06-24 15:16:40
 * @FilePath: \hdcms-nest\src\pipe\validate-pipe-custom.ts
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
import { ValidationError, ValidationPipe } from '@nestjs/common';

export class ValidatePipeCustom extends ValidationPipe {
  protected flattenValidationErrors(
    validationErrors: ValidationError[],
  ): any[] {
    return validationErrors.map((error) => {
      return {
        field: error.property,
        msg: Object.values(error.constraints),
      };
    });
  }
}
